<?php
namespace app\admin\controller;

use app\common\component\admin\AdminService;

class ControllerBase extends \think\Controller {
	public function checkLogin() {
		$resultIsLogin = (new AdminService()) -> isLogin();
		if($resultIsLogin['code'] !== 0) {
			echo '<meta charset="utf-8"><script>window.location.href="/shuashuale/login";</script>';exit;
		}
	}

	public function checkAuthorization() {
		$dispatch = $this -> request -> dispatch();
		$currentAction = 'app\\' . $dispatch['module'][0] . '\\controller\\' . $dispatch['module'][1] . '::' . $dispatch['module'][2];
		if(!in_array($currentAction, \think\Session::get('admin_role'), true)) {
			echo '<meta charset="utf-8"><script>alert("你没有当前操作的权限!");window.history.go(-1);</script>';exit;
		}
	}
}
?>